package com.example.smssenddemo;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class SmsSendListener implements View.OnClickListener {
    private Context context;
    private EditText address;
    private EditText content;

    public SmsSendListener(Context context, EditText address, EditText content) {
        this.context = context;
        this.address = address;
        this.content = content;
    }

    @Override
    public void onClick(View v) {
        PendingIntent pi = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
        SmsManager manager = SmsManager.getDefault();
        manager.sendTextMessage(address.getText().toString(), null, content.getText().toString(), pi, null);
        Toast.makeText(context, "短信发送成功！", Toast.LENGTH_LONG).show();
    }
}
